<!doctype html>
{php}
$static = '/static/home/';
{/php}
<!--[if IE 7]> <html lang="en" class="ie7"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title>{$siteConfig['seo_title']}</title>
    <meta name="apple-mobile-web-app-title" content="{$siteConfig['seo_title']}">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="{$static}images/favicon.ico">
    <link href="{$static}css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/icons.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/app.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/style.css" rel="stylesheet" type="text/css" />
</head>

<body data-sidebar="dark">

<!-- Begin page -->
<div id="layout-wrapper">

    {include file='public/mine_topbar' /}
    {include file='public/mine_left' /}

    <!-- ============================================================== -->
    <!-- Start right Content here -->
    <!-- ============================================================== -->
    <div class="main-content">

        <div class="page-content">
            <div class="container-fluid">

                <!-- start page title -->
                <div class="row">
                    <div class="col-12">
                        <div class="page-title-box d-flex align-items-center justify-content-between">
                            <h4 class="mb-0 font-size-18">账户设置</h4>

                            <div class="page-title-right">
                                <ol class="breadcrumb m-0">
                                    <li class="breadcrumb-item"><a href="javascript: void(0);">鹰眼短链</a></li>
                                    <li class="breadcrumb-item"><a href="{:url('account/index')}">账户设置</a></li>
                                    <li class="breadcrumb-item active">修改密码</li>
                                </ol>
                            </div>

                        </div>
                    </div>
                </div>
                <!-- end page title -->

                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <form class="js-ajax-form">
                                    <p class="card-title-desc">修改登录密码，需要输入旧密码</p>
                                    <div class="form-group row">
                                        <label class="col-md-2 col-form-label">账户密码</label>
                                        <div class="col-md-8">
                                            <input type="password" class="form-control" name="password" autocomplete="off" placeholder="请输入账户密码">
                                            <em for="password" class="invalid"></em>
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-md-2 col-form-label">新密码</label>
                                        <div class="col-md-8">
                                            <input type="password" class="form-control" name="newPassword1" autocomplete="off" placeholder="请输入新密码">
                                            <em for="newPassword1" class="invalid"></em>
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-md-2 col-form-label">确认新密码</label>
                                        <div class="col-md-8">
                                            <input type="password" class="form-control" name="newPassword2" autocomplete="off" placeholder="请确认新密码">
                                            <em for="newPassword2" class="invalid"></em>
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-md-2 col-form-label"></label>
                                        <div class="col-md-8">
                                            <button type="submit" class="btn btn-primary btn-block waves-effect">确认修改</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end row -->

            </div> <!-- container-fluid -->
        </div>
        <!-- End Page-content -->

    </div>
    <!-- end main content-->

</div>
<!-- END layout-wrapper -->

<!-- JAVASCRIPT -->
<script src="{$static}libs/jquery/jquery.min.js"></script>
<script src="{$static}libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="{$static}libs/metismenu/metisMenu.min.js"></script>
<script src="{$static}libs/simplebar/simplebar.min.js"></script>
<script src="{$static}libs/node-waves/waves.min.js"></script>
<script src="{$static}libs/layer/layer.js"></script>

<script src="{$static}js/pages/jquery.validate.min.js"></script>
<script src="{$static}js/app.js"></script>
<script>
    $(document).ready(function() {
        $(".js-ajax-form").validate({
            rules: {
                password: {
                    required: true,
                    minlength:6,
                    maxlength:32
                },
                newPassword1: {
                    required: true,
                    minlength:6,
                    maxlength:32
                },
                newPassword2: {
                    required: true,
                    minlength:6,
                    maxlength:32
                }
            },
            messages: {
                password: {
                    required: "请输入账户密码",
                    minlength: "请输入不少于6位长度密码",
                    maxlength: "密码的长度不能超过32位"
                },
                newPassword1: {
                    required: "请输入新密码",
                    minlength: "请输入不少于6位长度密码",
                    maxlength: "密码的长度不能超过32位"
                },
                newPassword2: {
                    required: "请确认新密码",
                    minlength: "请输入不少于6位长度密码",
                    maxlength: "密码的长度不能超过32位"
                }
            },
            submitHandler: function() {
                $.ajax({
                    url: "{:url('account/changePasswordAjax')}",
                    type: "POST",
                    data: $(".js-ajax-form").serialize(),
                    dataType: 'json',
                    async: true,
                    success: function (res) {
                        if (res.errorCode === 200) {
                            window.location.href = "{:url('account/index')}";
                        } else {
                            layer.alert(res.message, {
                                title: '提示',
                                icon: 2
                            });
                        }
                    }
                });
            },
            errorPlacement: function(error, element) {
                error.insertAfter(element.parent());
            }
        });
    });
</script>
</body>
</html>